home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.008.List.Line.Edit / Lists.inits.aii < prev    next >
Encoding:
Text File  |  1990-06-18  |  7.3 KB  |  354 lines  |  [TEXT/MPS ]

  1. *******************************************************************************
  2. *
  3. InitTools    PROC
  4. *
  5. * Description:    Load and initialize the tools needed. Errors are detected
  6. *    and FatalError is called if any occur. If there aren't any
  7. *    errors, the list of menu templates is read and the menu-
  8. *    bar is created.
  9. *
  10. *
  11. * Inputs:    NONE
  12. *
  13. * Outputs:    NONE
  14. *
  15. * External Refs:
  16.     import FatalError
  17. *
  18. * Entry Points:    NONE
  19. *
  20. *******************************************************************************
  21.     with Globals
  22.  
  23. ;
  24. ;   Tool Direct page offsets here
  25. ;
  26. QDDPage    equ $0000
  27. EMDPage    equ QDDPage+$0300
  28. CtlDPage    equ EMDPage+$0100
  29. MenuDPage    equ CtlDPage+$0100
  30. LEDPage    equ MenuDPage+$0100
  31. ToolDPSize    equ LEDPage+$0100
  32.  
  33.     phk    ; Save program bank register and
  34.     plb    ; load it as the data bank register
  35.  
  36.     tdc
  37.     sta MyDP    ; Save direct register
  38.  
  39.     _TLStartup    ; Start Tool Locator
  40.  
  41.     pha    ; Space for result
  42.     _MMStartup    ; Start memory manager
  43.     PullWord MyID    ; Save it for later use
  44.  
  45.     _MTStartup    ; Start up Misc Tools
  46.  
  47.     _IMStartup    ; Start integer math toolset
  48.  
  49.     PushLong #ToolTable    ; Pointer to Tool table
  50.     _LoadTools    ; Load all RAM based tools
  51.     bcc IT0005    ; Carry clear means no error
  52.     brl FatalError    ; Tools can't be loaded. Fatal error!
  53.  
  54. IT0005
  55.  
  56. ; Get memory for Tool Direct pages
  57.  
  58.     pha    ; Room for result
  59.     pha
  60.     PushLong #ToolDPSize; Number of bytes needed
  61.     PushWord MyID    ; ID of this application
  62.     PushWord #attrLocked+attrFixed+attrPage+attrBank
  63.     PushLong #0    ; Allocate them in bank 0
  64.     _NewHandle
  65.     bcc IT0010    ; Test carry for error
  66.     brl FatalError    ; If no memory we got a fatal error!
  67.  
  68. IT0010    PullLong DPHandle    ; Retrieve handle to our DPage area
  69.  
  70.     lda [DPHandle]    ; Dereference the handle to get a ptr
  71.     sta DPPointer    ; to our direct page area and save it.
  72.  
  73.     PushWord DPPointer    ; QuickDraw uses 3 pages of Dpage
  74.     PushWord #ScreenMode; Used to set all master SCB's
  75.     PushWord #0    ; Zero means use default buf size
  76.     PushWord MyID    ; Application ID for allocating data
  77.     _QDStartup    ; Start QuickDraw, turn on SHR Screen
  78.     bcc IT0015
  79.     brl FatalError    ; If it can't be started then bomb
  80.  
  81. IT0015
  82.     lda DPPointer    ; Create address for Event Mgr DPage by
  83.     clc    ; loading in the pointer to the start
  84.     adc #EMDPage    ; of DPage and adding Evt Mgr offset.
  85.     pha    ; Now push it on the stack.
  86.     PushWord #20    ; Size of event queue.
  87.     PushWord #0    ; MouseClamp values.
  88.     PushWord #ScreenWidth ; These will clamp mouse to screen
  89.     PushWord #0    ; area only.
  90.     PushWord #200
  91.     PushWord MyID
  92.     _EMStartup    ; Start the event manager
  93.     bcc IT0020
  94.     brl FatalError    ; Event manager is also a must
  95. IT0020
  96.     PushWord MyID
  97.     _WindStartup
  98.     bcc IT0025
  99.     brl FatalError
  100. IT0025
  101.     PushWord MyID
  102.     lda DPPointer
  103.     clc
  104.     adc #CtlDPage
  105.     pha
  106.     _CtlStartup
  107.     bcc IT0030
  108.     brl FatalError
  109. IT0030
  110.  
  111.     PushWord MyID
  112.     lda DPPointer
  113.     clc
  114.     adc #MenuDPage
  115.     pha
  116.     _MenuStartUp
  117.     bcc IT0035
  118.     brl FatalError
  119. IT0035
  120.     PushWord MyID
  121.     lda DPPointer
  122.     clc
  123.     adc #LEDPage
  124.     pha
  125.     _LEStartUp
  126.     bcc IT0040
  127.     brl FatalError
  128. IT0040
  129.     PushWord MyID
  130.     _DialogStartup
  131.     bcc IT0045
  132.     brl FatalError
  133. IT0045
  134.     _ScrapStartup    ; No errors possible for this call
  135.  
  136.     _DeskStartup    ; No error possible for this call
  137.  
  138. ; insert application specific tools here
  139.  
  140.     _ListStartup
  141.  
  142.     PushLong #0
  143.     _RefreshDeskTop
  144.  
  145. ;
  146. ; Create the menus I need
  147. ;
  148.  
  149.     ldx #MenuPtrLen-4    ; Get a pointer to the last menu    
  150. loop    phx    ; Save menu table index on the stack
  151.     pha    ; Push on space for the menu handle
  152.     pha    ;   returned by NewMenu
  153.     lda MenuPtr+2,x    ; Push on the pointer to the template
  154.     pha    ;   to be used by NewMenu when
  155.     lda MenuPtr,x    ;   creating the menu
  156.     pha
  157.     _NewMenu    ; Create a new menu
  158.     PushWord #0    ; Tell InsertMenu where to put it
  159.     _InsertMenu    ; Insert it.
  160.     plx    ; Get our index back off the stack
  161.     dex    ; Point to the next template pointer
  162.     dex
  163.     dex
  164.     dex
  165.     bpl loop    ; Go back up if not done yet.
  166.  
  167.     PushWord #1    ; Add NDA's
  168.     _FixAppleMenu
  169.  
  170.     pha    ; Now call CalcMenuSize for all menus
  171.     _FixMenuBar
  172.     PullWord MenuHeight
  173.  
  174.     _DrawMenuBar    ; Finally, draw it.
  175.  
  176.     RTS
  177.  
  178. ToolTable    dc.W 7    ; Data Block for LoadTools call
  179.     dc.W 14,$0100    ; Window Manager
  180.     dc.W 15,$0100    ; Menu Manager
  181.     dc.W 16,$0100    ; Control Manager
  182.     dc.W 20,$0100    ; LineEdit tool set
  183.     dc.W 21,$0100    ; Dialog Manager
  184.     dc.W 22,$0100    ; Scrap manager
  185.     dc.W 28,$0100    ; List Manager
  186.  
  187.     ENDP
  188.  
  189.     EJECT
  190. *******************************************************************************
  191. *
  192. FatalError    PROC
  193. *
  194. * Description:    Routine that is called whenever a tool sends back an error
  195. *    that can not be recovered from. This routine prints the
  196. *    error on the screen, waits for a keypress then quits back
  197. *    to whoever started this application up!
  198. *
  199. *
  200. * Inputs:    A = Error number
  201. *
  202. * Outputs:    NONE (program exits)
  203. *
  204. * External Refs:
  205.     import CloseTools
  206. *
  207. * Entry Points:    NONE
  208. *
  209. *******************************************************************************
  210.     with Globals
  211.  
  212.     pha    ; Push the error code
  213.     PushLong #ErrNumStr    ; Address of storage area
  214.     PushWord #4    ; Length of string
  215.     _Int2Hex
  216.  
  217.     _GrafOff    ; If QD Started, shut off graphics
  218.  
  219.     PushLong #ErrStr    ; Write error message to the screen
  220.     _WriteCString
  221.  
  222.     pha    ; Space for result
  223.     PushWord #0    ; No echo
  224.     _ReadChar    ; Wait for a key to be pressed
  225.     pla    ; Discard the key
  226.  
  227.     jsr CloseTools    ; Shut down all the tools in case
  228. ;          any got started up
  229.  
  230.     _Quit QuitParms    ; Quit back to where we came from.
  231.  
  232.     brk $FF    ; If the quit fails then just break
  233.     
  234. ErrStr    dc.B 'A fatal error has occured $'
  235. ErrNumStr    dc.B 'xxxx   press any key to exit',0
  236.  
  237.     ENDP
  238.  
  239.     EJECT
  240. *******************************************************************************
  241. *
  242. CloseTools    PROC
  243. *
  244. * Description:    Shut down the tools I started.
  245. *
  246. *
  247. * Inputs:    NONE
  248. *
  249. * Outputs:    NONE
  250. *
  251. * External Refs:    NONE
  252. *
  253. * Entry Points:    NONE
  254. *
  255. *******************************************************************************
  256.     with Globals
  257.  
  258.     _ListShutdown
  259.     _DeskShutDown
  260.     _ScrapShutDown
  261.     _DialogShutDown
  262.     _LEShutDown
  263.     _MenuShutDown
  264.     _CtlShutDown
  265.     _WindShutDown
  266.     _EMShutDown
  267.     _QDShutDown
  268.     _MTShutDown
  269.  
  270.     PushLong DPHandle    ; Dispose of all that DP memory
  271.     _DisposeHandle
  272.  
  273.     PushWord MyID
  274.     _MMShutDown
  275.     _TLShutDown
  276.  
  277.     rts
  278.     ENDP
  279.  
  280.     EJECT
  281. *******************************************************************************
  282. *
  283. doAbout    PROC
  284. *
  285. * Description:    Bring up an Alert Dialog box with our name in it.
  286. *
  287. * Inputs:    NONE
  288. *
  289. * Outputs:    NONE
  290. *
  291. * External Refs:    NONE
  292. *
  293. * Entry Points:    NONE
  294. *
  295. *******************************************************************************
  296.     With Globals
  297.  
  298.     pha    ; space for result
  299.     PushLong #AboutBox    ; pointer to alert template
  300.     PushLong #0    ; pointer to a filter proc (0=none)
  301.     _NoteAlert
  302.     pla    ; get the item hit and dispose
  303.  
  304.     rts
  305.  
  306. ; About Box alert template
  307.  
  308. AboutBox    dc.W 30,30,100,590    ; for 320 use 30,30,100,290
  309.     dc.W 1    ; this is alert # 1
  310.     dc.B $80    ; draw for this stage
  311.     dc.B $81    ; draw for this stage
  312.     dc.B $82    ; draw for this stage
  313.     dc.B $83    ; draw for this stage
  314.     dc.L OKButton    ; ok button for the    alert
  315.     dc.L AboutTitle    ; title of the program
  316.     dc.L AboutAut    ; author
  317.     dc.L AboutVers    ; version number string
  318.     dc.L 0    ; nil to end the list
  319.  
  320. OKBTitle    dc.B 2,'OK'
  321. OKButton    dc.W 1
  322.     dc.W 50,500,65,550
  323.     dc.W buttonItem
  324.     dc.L OKBTitle
  325.     dc.W 0
  326.     dc.W 0    ; item flag
  327.     dc.L 0    ; no color table
  328.  
  329. AboutTitle    dc.W 2
  330.     dc.W 10,100,20,550
  331.     dc.W statText+itemDisable
  332.     dc.L TitleString
  333.     dc.W 0
  334.     dc.W 0    ; item flag
  335.     dc.L 0    ; no color table
  336.  
  337. AboutAut    dc.W 3
  338.     dc.W 25,100,35,550
  339.     dc.W statText+itemDisable
  340.     dc.L AutString
  341.     dc.W 0
  342.     dc.W 0    ; item flag
  343.     dc.L 0    ; no color table
  344.  
  345. AboutVers    dc.W 4
  346.     dc.W 40,100,50,550
  347.     dc.W statText+itemDisable
  348.     dc.L VersString
  349.     dc.W 0
  350.     dc.W 0    ; item flag
  351.     dc.L 0    ; no color table
  352.  
  353.     ENDP
  354.